﻿using System.Windows;
using MyFloridaHouse.libSvDTO;

namespace MyFloridaHouse.libSvOpenDistricts.PDF
{

    public class PDFShapeName
    {
        public PDFString name { get; set; }
        public int regionID { get; set; }
        public int layerID { get; set; }
        public PDFShapeNamePosition position { get; set; }

        public BoundingBoxDTO shapeBoundingBoxLatLon { get; set; }
        public BoundingBoxDTO mapBoundingBoxLatLon { get; set; }
        public Rect mapInsetXYRect { get; set; }
        public double zoomLevel { get; set; }

        public PDFShapeName(int regionID, int layerID, PDFString shapeName, PointDTO shapeCenterLatLon, BoundingBoxDTO shapeBoundingBoxLatLon, BoundingBoxDTO mapBoundingBoxLatLon, Rect mapInsetXYRect, double zoomLevel)
        {
            this.layerID = layerID;
            this.regionID = regionID;
            this.name = shapeName;

            this.shapeBoundingBoxLatLon = shapeBoundingBoxLatLon;
            this.mapBoundingBoxLatLon = mapBoundingBoxLatLon;
            this.mapInsetXYRect = mapInsetXYRect;
            this.zoomLevel = zoomLevel;

            mapInsetXYRect = UpdateCenterPoint(shapeCenterLatLon);
        }

        public Rect UpdateCenterPoint(PointDTO shapeCenterLatLon)
        {
            PDFPoint centerpoint = PDFdoc.ConvertPointToXY(mapBoundingBoxLatLon, mapInsetXYRect, shapeCenterLatLon.longitude, shapeCenterLatLon.latitude, zoomLevel);
            position = new PDFShapeNamePosition(centerpoint, name.textBoxSize.Width, name.textBoxSize.Height);

            return mapInsetXYRect;
        }
    }
}
